<div id="app">
    <el-card class="box-card">
        <el-form ref="form"  :model="form" label-width="100px">
            <el-form-item label="订单状态：" >
                <el-radio-group v-model="labelPosition" size="small" @input="change">
                    <el-radio-button v-if="admin_type!=2" label="1">未下单 <span style="color:green;">{{status_d.status_1}}</span></el-radio-button>
                    <el-radio-button label="2" >待审核 <span style="color:green;">{{status_d.status_2}}</span></el-radio-button>
                    <el-radio-button label="3">审核通过 <span style="color:green;">{{status_d.status_3}}</span></el-radio-button>
                    <el-radio-button v-if="admin_type!=2" label="4" >审核驳回 <span style="color:green;">{{status_d.status_4}}</span></el-radio-button>
                    <el-radio-button label="10"  >已打印 <span style="color:green;">{{status_d.status_10}}</span></el-radio-button>
                    <el-radio-button label="6" >出库完成 <span style="color:green;">{{status_d.status_6}}</span></el-radio-button>
<!--                    <el-radio-button v-if="admin_type!=2" label="7">已取消</el-radio-button>-->
                    <el-radio-button label="8" >有售后 <span style="color:red;">{{status_d.admin_count}}</span></el-radio-button>
                    <el-radio-button v-if="admin_type!=1" label="9" >售后完成 <span style="color:green;">{{status_d.status_9}}</span></el-radio-button>
                    <el-radio-button label="">全部 </el-radio-button>
                </el-radio-group>
            </el-form-item>
        </el-form>
        <el-form :inline="true">
<!--            <el-form-item label="订单编号：" label-width="100px">-->
<!--                <div style="display: flex;width: 300px;">-->
<!--                    <el-input  placeholder="请输入订单号" v-model="data.order_no"></el-input>-->
<!--                    <el-button type="primary" icon="el-icon-search" @click="search_get_list" ></el-button>-->
<!--                </div>-->
<!--            </el-form-item>-->
<!--            <el-form-item label="收货人：" label-width="100px">-->
<!--                <div style="display: flex;width: 300px;">-->
<!--                    <el-input v-model="data.consignee" placeholder="请输入收货人姓名"></el-input>-->
<!--                    <el-button type="primary" icon="el-icon-search" @click="search_get_list" ></el-button>-->
<!--                </div>-->
<!--            </el-form-item>-->
            <el-form-item label="联系电话：" label-width="100px">
                <div style="display: flex;width: 300px;">
                    <el-input v-model="data.contact_phone" placeholder="请输入联系电话 "></el-input>
                    <el-button type="primary" icon="el-icon-search" @click="search_get_list" ></el-button>
                </div>
            </el-form-item>

        </el-form>
        <div style="display: flex;">
            <button style="margin-right: 20px;height: 32px;font-size: 12px;border-radius: 3px;" v-if="admin_type!=2" class="layui-btn layui-btn-normal layui-btn-sm" data-open="ord.order/add" data-title="新建订单" data-full="true" data-table="currentTableRenderId"><i class="fa fa-plus "></i> 新建订单</button>
            <div v-if="admin_type!=1" style="display: flex;align-items: center;">
                <el-button  size="small" type="primary" @click="shenhe_all" >批量审核通过</el-button>
            </div>
        </div>
        <div style="height: 30px;"></div>
        <el-table v-if="dataArr.length>0"
                :data="dataArr"
                border
                ref="multipleTable"
                tooltip-effect="dark"
                @selection-change="handleSelectionChange"
                :row-class-name="tableRowClassName"
                style="width: 100%;">
            <el-table-column
                    v-if="admin_type!=1"
                    type="selection"
                    width="55">
            </el-table-column>
            <el-table-column
                    prop="consignee"
                    label="收货人"
            >
            </el-table-column>
            <el-table-column v-if="admin_type!==1"
                             prop="employee_name"
                             label="负责人"
            >
            </el-table-column>
            <el-table-column v-if="admin_type!==1"
                    prop="order_bottom_price"
                    label="最低价"
            >
                <template slot-scope="{row}" >
                    <span v-if="parseInt(row.order_bottom_price) >parseInt(row.amount_collected)" style="color: rgb(229, 19, 0);">{{row.order_bottom_price}}</span>
                    <span v-else>{{row.order_bottom_price}}</span>
                </template>
            </el-table-column>
            <el-table-column v-if="admin_type!==1"
                    prop="amount_collected"
                    label="收款金额"
            >
                <template slot-scope="{row}" >
                    <span v-if="parseInt(row.order_bottom_price)>parseInt(row.amount_collected)" style="color: rgb(229, 19, 0);">{{row.amount_collected}}</span>
                    <span v-else>{{row.amount_collected}}</span>
                </template>
            </el-table-column>
            <el-table-column v-if="admin_type!=1"
                             prop="collection_voucher"
                             label="收款凭证"
                             width="330"
            >
                <template slot-scope="{row}" v-if="row.collection_voucher">
                    <el-image v-for="item of row.collection_voucher.split(',')"
                              style="width: 100px; height: 100px"
                              :src="item"
                              :preview-src-list="row.collection_voucher.split(',')"
                              fit="contain">
                    </el-image>
                </template>
            </el-table-column>


            <el-table-column
                    prop="reason"
                    label="驳回原因"
            >
            </el-table-column>
            <el-table-column
                    prop="remark"
                    label="备注"
                    width="110"
            >
            </el-table-column>
<!--            <el-table-column v-if="admin_type!=2"-->
<!--                    prop="contact_phone"-->
<!--                    label="联系电话"-->
<!--                    width="110"-->
<!--            >-->
<!--            </el-table-column>-->

            <el-table-column
                    prop="status"
                    label="订单状态"
            >
                <template slot-scope="{row}">
                    <span v-if="row.status==1" style="color: #666666;">未下单</span>
                    <span v-else-if="row.status==2" style="color: #FF8800;">待审核</span>
                    <span v-else-if="row.status==3" style="color: #24B364;">审核通过</span>
                    <span v-else-if="row.status==4" style="color: #E51300 ;">审核驳回</span>
<!--                    <span v-else-if="row.status==5" style="color: #666666;">已退款</span>-->
                    <span v-else-if="row.status==6" style="color: #007BF0 ;">出库完成</span>
<!--                    <span v-else-if="row.status==7 " style="color: #999999;">已取消</span>-->
                    <span v-else-if="row.status==8 " style="color: #E51300 ;">有售后</span>
                    <span v-else-if="row.status==9 " style="color: #E51300 ;">售后完成</span>
                    <span v-else-if="row.status==10 " style="color: #E51300 ;">已打印</span>
                </template>
            </el-table-column>

            <el-table-column label="操作" width="200">
                <template slot-scope="{row}">
                    <div v-if="row.admin_type==0">
                        <div v-if="row.is_change==2&&row.change_status==1">
                           <div>变更审核中</div><el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>

                        </div>
                        <div v-else-if="row.status==1">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <a href="javaScript:;" style="color: #409EFF;font-size: 12px;" class="layui-btn-success" :data-open="'ord.order/edit?id='+row.id" data-full="true">编辑</a>
                        </div>
                        <div v-else-if="row.status==2">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" @click="examine(row.id)">审核</el-button>
                            <el-button type="text" size="mini" @click="cancel_order(row.id)">取消订单</el-button>
                        </div>
                        <div v-else-if="row.status==3">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text"  v-if="(row.change_status==0 || row.change_status==3) || (row.change_status==2 && row.is_edit==1)" size="mini" @click="change_info(row.id)">变更信息</el-button>
                            <a href="javaScript:;" v-if="row.change_status==2 && row.is_edit!==1" style="color: #409EFF;font-size: 12px;" class="layui-btn-success" :data-open="'ord.order/edit?id='+row.id" data-full="true">编辑</a>
                        </div>
                        <div v-else-if="row.status==4">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <a  href="javaScript:;" style="color: #409EFF;font-size: 12px;" class="layui-btn-success" :data-open="'ord.order/edit?id='+row.id" data-full="true">编辑</a>
                            <!--                            <el-button type="text"  v-if="row.change_status==0 || row.change_status==3" size="mini" @click="change_info(row.id)">变更信息</el-button>-->
                        </div>
                        <div v-else-if="row.status==5">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" v-if="row.is_cooperate==1" size="mini" @click="export_world(row.id)">打印</el-button>
                            <el-button type="text"  v-if="(row.change_status==0 || row.change_status==3) || (row.change_status==2 && row.is_edit==1)" size="mini" @click="change_info(row.id)">变更信息</el-button>
                            <a href="javaScript:;" v-if="row.change_status==2 && row.is_edit!==1" style="color: #409EFF;font-size: 12px;" class="layui-btn-success" :data-open="'ord.order/edit?id='+row.id" data-full="true">编辑</a>
                        </div>
                        <div v-else-if="row.status==6">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" @click="change_info(row.id,row.status)">变更信息</el-button>
                        </div>
                        <div v-else-if="row.status==7">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                        </div>
                        <div v-else-if="row.status==8">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" @click="playEnd(row.id)">处理结果</el-button>
                            <el-button type="text" size="mini" @click="handleEnd(row.id)">已完结</el-button>
                        </div>
                        <div v-else-if="row.status==9">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <!--                            <el-button type="text" size="mini" v-if="row.change_status==0 || row.change_status==3" @click="change_info(row.id,row.status)">变更信息</el-button>-->
                        </div>
                        <div v-else-if="row.status==10">
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" v-if="row.change_status==0 || row.change_status==3" @click="change_info(row.id,row.status)">变更信息</el-button>
                        </div>
                    </div>
                    <div v-if="row.admin_type==1">
                        <div v-if="row.is_change==2&&row.change_status==1">
                            <div>变更审核中</div><el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                        </div>
                        <div v-else>
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button v-if="row.status==2" type="text" size="mini" @click="cancel_order(row.id)">取消订单</el-button>
                            <div v-if="row.status==3 || row.status==5 || row.status==6">
                                <el-button v-if="(row.change_status==0 || row.change_status==3) || (row.change_status==2 && row.is_edit==1)" type="text" size="mini" @click="change_info(row.id,row.status)">变更信息</el-button>
                            </div>
                            <div v-if="row.status==3 || row.status==5 ">
                                <a href="javaScript:;" v-if="row.change_status==2 && row.is_edit!==1" style="color: #409EFF;font-size: 12px;" class="layui-btn-success" :data-open="'ord.order/edit?id='+row.id" data-full="true">编辑</a>
                            </div>
                            <div v-else-if="row.status==1 || row.status==4">
                                <a href="javaScript:;"  style="color: #409EFF;font-size: 12px;" class="layui-btn-success" :data-open="'ord.order/edit?id='+row.id" data-full="true">编辑</a>
                            </div>
                            <div v-else-if="row.status==10">
                                <el-button type="text" size="mini" v-if="row.change_status==0 || row.change_status==3" @click="change_info(row.id,row.status)">变更信息</el-button>
                            </div>
                        </div>
                    </div>
                    <div v-if="row.admin_type==2">
                        <div v-if="row.is_change==2&&row.change_status==1">
                            <div>变更审核中</div><el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                        </div>
                        <div v-else>
                            <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                            <el-button type="text" size="mini" v-if="row.is_cooperate==1 && row.status==5" @click="export_world(row.id)">打印</el-button>
                            <div v-if="row.status==2">
                                <el-button type="text" size="mini" @click="examine(row.id)">审核</el-button>
                            </div>
                            <div v-else-if="row.status==3">
<!--                                <el-button type="text" size="mini" @click="yuyue(row.id,row.is_cooperate,row.cooperative_express)">预约快递</el-button>-->
                            </div>
                            <div v-else-if="row.status==5">
                            </div>
                            <div v-else-if="row.status==8">
                                <el-button type="text" size="mini" @click="playEnd(row.id)">处理结果</el-button>
                                <el-button type="text" size="mini" @click="handleEnd(row.id)">已完结</el-button>
                            </div>
                        </div>
                    </div>
                </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="10"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </div>
    </el-card>
    <el-dialog
            title="订单详情"
            :visible.sync="dialogVisible"
            width="85%"
            >
            <div v-if="active_int==1">
                <div >
                    <el-button  type="primary" id="btncopy" :data-clipboard-text="CopyText">
                        一键复制
                    </el-button>
                </div>
                <div class="border">
                    <fieldset class="layui-elem-field layui-field-title">
                        <legend style="font-weight: bold;font-size: 16px;">收货信息</legend>
                    </fieldset>
                    <table style="width: 100%;line-height: 1.8;" class="table">
                        <tr>
                            <td >收货：{{detail_obj.consignee}}</td>
                            <td>联系电话：{{detail_obj.contact_phone}}</td>
                            <td >收货地址：{{detail_obj.provinces}}{{detail_obj.city}}{{detail_obj.area}}{{detail_obj.address}}</td>
                        </tr>
                    </table>
<!--                    <div class="tit"></div>-->
                    <fieldset class="layui-elem-field layui-field-title" style="font-weight: bold;">
                        <legend style="font-weight: bold;font-size: 16px;">订单信息</legend>
                    </fieldset>
                    <table style="width: 100%;line-height: 2;">
                        <tr>
                            <td>订单编号：{{detail_obj.order_no}}</td>
                            <td>负责人：{{detail_obj.new_employee_name}}</td>
                            <td>收款金额：{{detail_obj.amount_collected}}</td>
                        </tr>
                        <tr>
                            <td>下单时间：{{detail_obj.create_time}}</td>
                            <td>订单状态：{{
                                detail_obj.status==1?'未下单':
                                detail_obj.status==2?'待审核':
                                detail_obj.status==3?'审核通过':
                                detail_obj.status==4?'审核驳回':
                                detail_obj.status==6?'出库完成':
                                detail_obj.status==10?'已打印':
                                detail_obj.status==8?'有售后':
                                detail_obj.status==9?'售后完成':''
                                }}
                            </td>
<!--                            <td >订单审核：{{detail_obj.change_auditor}}</td>-->
                            <td >订单驳回原因：{{detail_obj.reason}}</td>

                        </tr>
                        <tr>

                            <td>备注：{{detail_obj.remark}}</td>
                        </tr>
                        <tr v-if="detail_obj.status==6">
                            <td >出库员：{{detail_obj.discrepancy}}</td>
                            <td >出库时间：{{detail_obj.create_time}}</td>
                        </tr>
                        <tr v-if="detail_obj.completed_by">
                            <td >售后处理员：{{detail_obj.completed_by}}</td>
                            <td >处理时间：{{detail_obj.completed_time}}</td>
                        </tr>
                    </table>
                    <fieldset class="layui-elem-field layui-field-title">
                        <legend style="font-weight: bold;font-size: 16px;">收款凭证</legend>
                    </fieldset>
                    <div style="display: flex;align-items: center;" v-if="detail_obj.collection_voucher">
                        <el-image v-for="item of detail_obj.collection_voucher"
                             style="width: 100px; height: 100px;margin: 10px 0;border: 1px solid #ccc;"
                             :src="item"
                             :preview-src-list="detail_obj.collection_voucher"
                             fit="contain">
                        </el-image>
                    </div>
                    <fieldset class="layui-elem-field layui-field-title" v-if="detail_obj.void_picture">
                        <legend style="font-weight: bold;font-size: 16px;">处理结果</legend>
                    </fieldset>
                    <div style="display: flex;align-items: center;" v-if="detail_obj.void_picture">
                        <el-image v-for="item of detail_obj.void_picture"
                                  style="width: 100px; height: 100px;margin: 10px 0;border: 1px solid #ccc;"
                                  :src="item"
                                  :preview-src-list="detail_obj.void_picture"
                                  fit="contain">
                        </el-image>
                    </div>
                    <div v-if="detail_obj.void_characters">处理说明：{{detail_obj.void_characters}}</div>
                    <fieldset class="layui-elem-field layui-field-title" >
                        <legend style="font-weight: bold;font-size: 16px;">商品信息</legend>
                    </fieldset>
                    <el-table :data="detail_obj.order_item"
                              border>
                    <el-table-column label="商品" prop="good_name" width="200"></el-table-column>
                    <el-table-column label="数量" prop="num" width="110"></el-table-column>
                    </el-table>
                </div>
            </div>
            <div v-else-if="active_int==2">
                <div v-if="row.status==2">
                    <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                    <el-button type="text" size="mini" @click="examine(row.id)">审核</el-button>
                </div>
                <div v-else>
                    <el-button type="text" size="mini" @click="detail_show(row)">详情</el-button>
                </div>
            </div>

        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
    <el-dialog
            title="变更提示"
            :visible.sync="dialogVisible_change"
            width="30%"
            >
        <el-select v-model="change_info_val">
            <el-option label="收货信息"
                       :value="1"></el-option>
            <el-option label="订单商品"
                       :value="2"></el-option>
        </el-select>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible_change = false">取 消</el-button>
    <el-button type="primary" @click="success">确 定</el-button>
  </span>
    </el-dialog>

    <el-dialog
            title="修改审核状态"
            :visible.sync="dialogVisible_refuse"
            width="30%"
    >
        <el-form >
            <el-form-item label="审核状态：" label-width="100px">
                <el-select v-model="change_refuse_val">
                    <el-option label="通过"
                               :value="1"></el-option>
                    <el-option label="驳回"
                               :value="2"></el-option>
                </el-select>
            </el-form-item>
                <el-form-item v-if="change_refuse_val==2" label="驳回原因：" label-width="100px">
                    <el-input
                            type="textarea"
                            :rows="2"
                            placeholder="请输入内容"
                            v-model="refuse_textarea">
                    </el-input>
                </el-form-item>


        </el-form>

        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible_refuse = false">取 消</el-button>
    <el-button type="primary" @click="success_refuse">确 定</el-button>
  </span>
    </el-dialog>


    <el-dialog
            title="上传处理结果图片"
            :visible.sync="dialogVisible_upload"
            width="60%"
            :show-close="false"
    >
        <div style="width: 1200px;">
            <el-upload
                    action="/admin/ajax/upload"
                    list-type="picture-card"
                    :on-preview="handlePictureCardPreview"
                    :on-success="handleAvatarSuccessList"
                    :before-upload="beforeAvatarUpload"
                    :file-list="imgList"
                    :on-remove="handleRemove">
                <i class="el-icon-plus"></i>

            </el-upload>

            <div style="width: 400px;">
                <el-input
                        placeholder="请输入未完结处理文字描述"
                        v-model="void_characters">
                </el-input>
            </div>
        </div>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible_upload = false;imgList=[];void_characters='';">取 消</el-button>
    <el-button type="primary" @click="success_upload">确 定</el-button>
  </span>
    </el-dialog>
    <el-dialog :visible.sync="dialogVisibleImage">
        <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
</div>
<script !src="">
    new Vue({
        el: '#app',
        data: function() {
            return {
                options: [{
                    value: '顺丰',
                    label: '顺丰'
                }, {
                    value: '申通',
                    label: '申通'
                }, {
                    value: '圆通',
                    label: '圆通'
                },{
                    value: '韵达',
                    label: '韵达'
                },{
                    value: '极兔',
                    label: '极兔'
                }],
                radio:1,
                form:{},
                dataArr:[],
                labelPosition:2,
                bh:'',
                data:{
                    page:1,
                    limit:10,
                    order_no:'',
                    consignee:'',
                    contact_phone:'',
                    status:2,
                    is_cooperate:'',
                },
                admin_type:"{$admin_type}",
                total:0,
                currentPage:1,
                dialogVisible: false,
                dialogVisible_change:false,
                active_int:1,
                detail_obj:{},
                dialogImageUrl:'',
                imgList:[],
                dialogVisible_yuyue:false,
                dialogVisible_refuse:false,
                dialogVisible_upload:false,
                dialogVisibleImage:false,
                change_refuse_val:1,
                refuse_textarea:'',
                change_info_val:1,
                change_info_id:'',
                preaives:[],
                citys:[],
                areas:[],
                yuyue_id:'',
                fullscreenLoading:false,
                appointment_data:{
                    id:'',
                    is_cooperate:'',
                    cooperative_express:'',
                    courier_number:''
                },
                multipleSelection:[],
                refuse_id:'',
                image:'',
                image_arr:[],
                play_id:'',
                CopyText:'',
                void_characters:'',
                dialogVisibleImg:false,
                status_d:{
                    status_1:"",
                    status_2:"",
                    status_3:"",
                    status_4:"",
                    status_5:"",
                    status_6:"",
                    status_9:"",
                    status_10:"",
                    admin_count:"",
                },
                ok_time:{
                    shenhe_time:0,
                    yuyue_time:0,
                    dayin_time:0,
                }
            }
        },
        created(){
            this.get_list()
            this.get_status_data()

        },
        methods:{

            get_status_data(){

                $.ajax({
                        url:"/admin/ord.order/status_data",
                        type:'GET',
                        dataType: 'json',
                        success:(res)=>{
                            console.log(res.data,'res')
                            this.status_d = res.data
                        }
                })
            },
            keyCopy(){
                new ClipboardJS('.btn', {
                    text: function(trigger) {
                        return trigger.getAttribute('aria-label');
                    }
                });
            },
            success_upload(){
                $.ajax({
                    url:"/admin/chao.change_order/unfinished_img",
                    data:{id:this.play_id,image:this.image,void_characters:this.void_characters},
                    type:'POST',
                    dataType: 'json',
                    success:(res)=>{
                        if(res.code==1){
                            this.dialogVisible_upload = false
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    }
                })
            },
            handleRemove(file, fileList) {
                var url = file.url
                var index = this.image_arr.findIndex(d=>d==url)
                this.image_arr.splice(index,1)
                this.image = this.image_arr.join(',')
            },
            beforeAvatarUpload(){},
            handleAvatarSuccessList(res){
                if(!this.image_arr){
                    this.image_arr = []
                }
                this.image_arr.push(res.data.url)
                this.image = this.image_arr.join(',')
            },
            handlePictureCardPreview(file) {
                this.dialogImageUrl = file.url;
                this.dialogVisibleImage = true;
            },
            playEnd(id){
                this.imgList = []
                $.ajax({
                    url:"/admin/ord.order/ord_detail",
                    data:{id:id},
                    type:'GET',
                    dataType: 'json',
                    success:(res)=>{
                        if(res.code==1) {
                            this.play_id = id
                            this.dialogVisible_upload = true
                            this.image_arr = res.data.void_picture?res.data.void_picture:[]
                            var imgList = []
                            if(this.image_arr){
                                this.image_arr.map(data => {
                                    imgList.push({
                                        name: data,
                                        url: data
                                    })
                                })
                            }
                            this.imgList = imgList
                            this.void_characters = res.data.void_characters
                            this.image = this.image_arr.join(',')
                        }
                    }
                })
            },
            handleEnd(id){
                this.$confirm('确认完结当前作废订单的处理？', '提示', {
                    confirmButtonText: '确认',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.ajax({
                        url:"/admin/chao.change_order/chaorder_end",
                        data:{id},
                        type:'POST',
                        dataType: 'json',
                        success:(res)=>{
                            if(res.code==1){
                                var item = this.dataArr.find(d=>d.id==id)
                                item.status = 9
                                this.$message({
                                    type: 'success',
                                    message: res.msg
                                });
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        }
                    })
                }).catch(() => {

                });
            },
            success_refuse(){
                var id = this.refuse_id
                if(this.change_refuse_val==1){
                    const loading = this.$loading({
                        lock: true,
                        text: 'Loading',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    });
                       $.ajax({
                           url: "/admin/ord.order/pass_through",
                           data: {id},
                           type: 'POST',
                           dataType: 'json',
                           success: (res) => {
                               loading.close()
                                if (res.code == 1) {
                                        var item = this.dataArr.find(d => d.id == id)
                                        item.status = 3
                                    this.get_status_data()
                                    this.$message({
                                         type: 'success',
                                         message: res.msg
                                    });
                                    this.dialogVisible_refuse = false
                                } else {
                                    this.$message({
                                         type: 'info',
                                         message: res.msg
                                    });
                                }
                            },
                           error:()=>{
                               loading.close()
                               this.$message({
                                   type: 'info',
                                   message: '网络状态差'
                               });
                           }
                       })
                }else if(this.change_refuse_val==2){
                    if(this.refuse_textarea!==''){
                        const loading = this.$loading({
                            lock: true,
                            text: 'Loading',
                            spinner: 'el-icon-loading',
                            background: 'rgba(0, 0, 0, 0.7)'
                        });
                         $.ajax({
                             url:"/admin/ord.order/order_refuse",
                             data:{id,reason:this.refuse_textarea},
                             type:'POST',
                             dataType: 'json',
                             success:(res)=>{
                                 loading.close()
                                  if(res.code==1){
                                        var item = this.dataArr.find(d=>d.id==id)
                                        item.status = 4
                                      this.get_status_data()
                                        this.dialogVisible_refuse = false
                                        item.reason = this.refuse_textarea
                                             this.$message({
                                                    type: 'success',
                                                    message: res.msg
                                             });
                                  }else{
                                        this.$message({
                                             type: 'info',
                                             message: res.msg
                                        });
                                  }
                            },
                             error:()=>{
                                 loading.close()
                                 this.$message({
                                     type: 'info',
                                     message: '网络状态差'
                                 });
                             }
                         })
                    }
                }
            },
            tableRowClassName({row, rowIndex}) {
                if(row.status==1){
                    if(this.admin_type==2){
                        return 'none'
                    }
                }else if (row.status==2){
                    return 'warning-row';
                }else if(row.status==3){
                    return 'success-row';
                }else if(row.status==4){
                    return 'danger-row';
                }else{
                    return '';
                }
            },
            shenhe_all(){
                var now_time = new Date().getTime()
                if((now_time-this.ok_time.shenhe_time)<60000){
                    this.$message({
                        type: 'info',
                        message:'正在批量审核中，请稍等'
                    });
                    return false
                }
                var data_str = ''
                var data_arr = []
                if(this.multipleSelection.length===0){
                    this.$message({
                        type: 'info',
                        message:'请选择待审核的订单'
                    });
                    return false
                }
                var item = {}
                var isTest = true
                for (var i = 0;i<this.multipleSelection.length;i++){
                    item = this.multipleSelection[i]
                    data_arr.push(item.id)
                    if(item.status !==2){
                        this.$message({
                            type: 'info',
                            message:'请选择待审核的订单'
                        });
                        isTest = false
                        break;
                    }

                    if(item.change_status ===1){
                        this.$message({
                            type: 'info',
                            message:'有变更审核中的订单，请完成审核再操作'
                        });
                        isTest = false
                        break;
                    }

                }
                data_str = data_arr.join(',')
                var is_cooperate = 1
                if(isTest){
                    this.$confirm('确定批量审核'+data_arr.length+'项为通过', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.ok_time.shenhe_time = new Date().getTime()
                        const loading = this.$loading({
                            lock: true,
                            text: 'Loading',
                            spinner: 'el-icon-loading',
                            background: 'rgba(0, 0, 0, 0.7)'
                        });
                        $.ajax({
                            url:"/admin/ord.order/batch_pass",
                            data:{id:data_str},
                            type:'POST',
                            dataType: 'json',
                            success:(res)=>{
                                loading.close()
                                if(res.code==1){
                                    this.get_status_data()
                                    this.get_list()
                                    this.$message({
                                        type: 'success',
                                        message: res.msg
                                    });
                                }else{
                                    this.$message({
                                        type: 'info',
                                        message: res.msg
                                    });
                                }
                            },
                            error:()=>{
                                loading.close()
                                this.$message({
                                    type: 'info',
                                    message: '网络状态差'
                                });
                            }
                        })

                    })
                }
            },
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            success_yuyue(){
                if(this.appointment_data){
                    const loading = this.$loading({
                        lock: true,
                        text: 'Loading',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });

                    $.ajax({
                        url:"/admin/ord.order/complete_appointment",
                        data:this.appointment_data,
                        type:'POST',
                        dataType: 'json',
                        success:(res)=>{
                            loading.close();
                            if(res.code==1){
                                this.dialogVisible_yuyue = false
                                this.get_list()
                                this.get_status_data()
                                this.$message({
                                    type: 'success',
                                    message: res.msg
                                });
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                        error:()=>{
                            loading.close();
                            this.$message({
                                type: 'err',
                                message: '网络状态差'
                            });
                        }
                    })
                }else{
                    // this.$message({
                    //     type: 'info',
                    //     message: '快递单号不能为空！'
                    // });
                }
            },
            now_yuyue(){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/ord.order/complete_appointment",
                    data:this.appointment_data,
                    type:'POST',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();

                        if(res.code==1){
                            this.appointment_data.courier_number = res.data
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'err',
                            message: '网络状态差'
                        });
                    }
                })
            },

            export_world(id){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/ord.order/batch_print",
                    data:{id:id},
                    type:'POST',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            var item = this.dataArr.find(d=>d.id==id)
                            item.status = 10
                            this.get_status_data()
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'err',
                            message: '网络状态差'
                        });
                    }
                })
            },
            change(){
                this.data.status = this.labelPosition
                this.data.page = 1
                this.data.limit = 10
                this.dataArr = []
                this.get_list()
                this.get_status_data()
            },
            success(){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                    url:"/admin/ord.order/change_information",
                    data:{change_info:this.change_info_val,id:this.change_info_id},
                    type:'POST',
                    dataType: 'json',
                    success:(res)=>{
                        loading.close();
                        if(res.code==1){
                            var item = this.dataArr.find(d=>d.id==this.change_info_id)
                            item.change_info = this.change_info_val
                            item.change_status = 1
                            this.get_status_data()
                            this.get_list()
                            this.$message({
                                type: 'success',
                                message: res.msg
                            });
                        }else{
                            this.$message({
                                type: 'info',
                                message: res.msg
                            });
                        }
                    },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'err',
                            message: '网络状态差'
                        });
                    }
                })
                this.dialogVisible_change = false
            },
            change_info(id,status){
                if(status==6){
                    this.$confirm('订单已出库，是否作废当前订单重新下单？', '提示', {
                        confirmButtonText: '作废',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        const loading = this.$loading({
                            lock: true,
                            text: 'Loading',
                            spinner: 'el-icon-loading',
                            background: 'rgba(0, 0, 0, 0.7)'
                        });
                        $.ajax({
                            url:"/admin/chao.change_order/change_order_review",
                            data:{id},
                            type:'POST',
                            dataType: 'json',
                            success:(res)=>{
                                loading.close();
                                if(res.code==1){
                                    var item = this.dataArr.find(d=>d.id==id)
                                    item.status = 8
                                    this.get_status_data()
                                    this.$message({
                                        type: 'success',
                                        message: res.msg
                                    });
                                }else{
                                    this.$message({
                                        type: 'info',
                                        message: res.msg
                                    });
                                }
                            },
                            error:()=>{
                                loading.close();
                                this.$message({
                                    type: 'err',
                                    message: '网络状态差'
                                });
                            }
                        })
                    }).catch(() => {
                        // this.$message({
                        //     type: 'info',
                        //     message: '已取消作废'
                        // });
                    });
                }else{
                    this.dialogVisible_change = true
                    this.change_info_id = id
                }

            },
            cancel_order(id){
                this.$confirm('是否取消并作废此订单吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    const loading = this.$loading({
                        lock: true,
                        text: 'Loading',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    $.ajax({
                        url:"/admin/ord.order/cancel_order",
                        data:{id},
                        type:'POST',
                        dataType: 'json',
                        success:(res)=>{
                            loading.close();
                            if(res.code==1){
                                var item = this.dataArr.find(d=>d.id==id)
                                item.status = 7
                                this.get_status_data()
                                this.$message({
                                    type: 'success',
                                    message: res.msg
                                });
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                        error:()=>{
                            loading.close();
                            this.$message({
                                type: 'err',
                                message: '网络状态差'
                            });
                        }
                    })
                }).catch(() => {

                });
            },
            examine(id){
                this.dialogVisible_refuse = true
                this.refuse_id = id
                this.change_refuse_val = 1
                this.refuse_textarea = ''
            },
            onSubmit(){},
            detail_show(data){
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                $.ajax({
                        url:"/admin/ord.order/ord_detail",
                        data:{id:data.id},
                        type:'GET',
                        dataType: 'json',
                        success:(res)=>{
                            loading.close()
                            if(res.code==1){
                                this.dialogVisible = true;
                                this.active_int=1;

                                var detail_obj = res.data
                                this.detail_obj = detail_obj
                                $.ajax({
                                    url:'/admin/ord.order/get_preaive',
                                    dataType:"json",
                                    success:(res_p)=>{
                                        var province = res_p.data.find(item=>{
                                            return  item.id == detail_obj.provinces
                                        })
                                        $.ajax({
                                            url:'/admin/ord.order/city',
                                            data:{pid:detail_obj.provinces},
                                            dataType:"json",
                                            success:(res_c)=>{
                                                var city = res_c.data.find(item=>{
                                                    return  item.id == detail_obj.city
                                                })
                                                $.ajax({
                                                    url:'/admin/ord.order/area',
                                                    data:{cid:detail_obj.city},
                                                    dataType:"json",
                                                    success:(res_a)=>{
                                                        var area = res_a.data.find(item=>{
                                                            return  item.id == detail_obj.area
                                                        })
                                                        detail_obj.provinces = province.name
                                                        detail_obj.city = city.name
                                                        detail_obj.area = area?.name

                                                        var order_str = ''
                                                        detail_obj.order_item.map(item=>{
                                                            order_str+='\n'
                                                            order_str+=item.good_name
                                                            order_str+=' '
                                                            order_str+=item.num
                                                            order_str+=' '
                                                        })
                                                        var text = detail_obj.consignee+' '+
                                                            detail_obj.contact_phone+' '+
                                                            detail_obj.provinces+
                                                            detail_obj.city+
                                                            (detail_obj.area || '') +
                                                            detail_obj.address+' '+order_str

                                                        this.CopyText = text
                                                        this.detail_obj = detail_obj
                                                        var btn = document.getElementById('btncopy');
                                                        var clipboard = new ClipboardJS(btn);
                                                        var that = this
                                                        clipboard.once('success', function (e) {
                                                            that.$message({
                                                                type: 'success',
                                                                message: '复制成功 '
                                                            });
                                                        });
                                                        clipboard.once('error', function (e) {
                                                        });
                                                    }
                                                })
                                            }
                                        })
                                    }
                                })
                            }else{
                                this.$message({
                                    type: 'info',
                                    message: res.msg
                                });
                            }
                        },
                    error:()=>{
                        loading.close();
                        this.$message({
                            type: 'err',
                            message: '网络状态差'
                        });
                    }
                })
            },
            createOrder(){
                window.location.href = '/admin/ord.order/add'
            },
            handleSizeChange(val){
                this.data.limit = val
                this.get_list()
            },
            handleCurrentChange(val) {
                this.data.page = val
                this.get_list()
            },
            search_get_list(){
                this.data.page = 1
                this.data.limit = 10
                this.dataArr = []
                this.get_list()
            },
            get_list(){
                $.ajax({
                    url:'/admin/ord.order/index',
                    type:'GET',
                    data:this.data,
                    dataType:"json",
                    success:(res)=>{
                        this.dataArr = res.data
                        this.total = res.count
                    }
                })
            }
        },
        filters:{
            // getProvinces(val,prea){
            //     if(!val) return ''
            //     var data = prea.find(d=>d.id == val)
            //     return data.name
            // },
            // getCity(val,pid){
            //     if(!val) return ''
            //     $.ajax({
            //         url:'/admin/ord.order/city',
            //         data:{pid:pid},
            //         dataType:"json",
            //         success:(res)=>{
            //             console.log(res,'resold')
            //             return '王二'
            //         }
            //     })
            // },
            // getArea(val){
            //     if(!val) return ''
            //     console.log(val,'old')
            // },
        },
        mounted() {

        }
    })
</script>
<style>
    .el-table .warning-row {
        background: #FFF8E6;
    }

    .el-table .success-row {
        background: #E0FFEE;
    }
    .el-table .danger-row {
        background: #FFE5E5;
    }
    .el-table .none {
       display: none;
    }

    .border{
        padding: 20px;
        border: 1px solid rgba(232, 232, 232, 1);
    }
    .tit{
        font-weight: bold;
        height: 40px;
        line-height: 40px;
    }
    .el-dialog__body{
        padding-bottom:0;
    }
</style>
